export const NULL_RULES = (value: any) => !['', null, undefined].includes(value);

// 数据校验
export const validate = <T extends Record<string, any>>(
  data: T, 
  validateConfig: {[Key in keyof T]?: { rule: (value: any) => boolean, msg: string }[]}
) => {
  for (const key of Object.keys(data)) {
    const value = data[key];
    const config = validateConfig[key] ?? [];
    
    for (const item of config) {
      const res = item.rule(value);
      if (!res) return item.msg;
    }
  }

  return undefined;
};